﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace VisionCloud.Domain.DtoModel.Ms
{
    /// <summary>
    /// 俯视图与靠尺信息
    /// </summary>
    public class Planformpath
    {
        /// <summary>
        /// 俯视图
        /// </summary>
        public string planform_path { get; set; }

        /// <summary>
        /// "wall_flat"数组成员，"title"为墙面编号，得到当前墙面后，获取data数组，里面的"title"为靠尺编号，"value"为靠尺值
        /// </summary>
        public List<WallRuler> wall_flat { get; set; }

        /// <summary>
        /// "vertical_flat"数组成员，"title"为墙面编号，得到当前墙面后，获取data数组，里面的"title"为靠尺编号，"value"为靠尺值
        /// </summary>
        public List<WallRuler> vertical_flat { get; set; }
    }

    /// <summary>
    /// 墙面靠尺
    /// </summary>
    public class WallRuler
    {
        /// <summary>
        /// 墙面
        /// </summary>
        public string title { get; set; }

        /// <summary>
        /// 靠尺信息
        /// </summary>
        public List<RuleData> Data { get; set; } = new List<RuleData>();
    }

    /// <summary>
    /// 平整度\垂直度数组成员
    /// </summary>
    public class RuleData
    {
        public decimal x { get; set; } = 0;
        public decimal angle { get; set; } = 0;

        public Guid id { get; set; }

        /// <summary>
        /// 靠尺
        /// </summary>
        public string title { get; set; } = string.Empty;

        private decimal _value = 0;

        /// <summary>
        /// 靠尺值
        /// </summary>
        public decimal value
        {
            //get;set;
            get
            {
                return _value;
            }
            set
            {
                _value = Math.Round(value, 1);
            }
        }

        /// <summary>
        /// 靠尺选中否
        /// </summary>
        public bool flag { get; set; } = true;

        /// <summary>
        /// 靠尺类型
        /// </summary>
        public string type { get; set; }
    }

    /// <summary>
    /// tackpointchangejson靠尺变更信息
    /// </summary>
    public class WallRulerChange
    {
        /// <summary>
        /// 墙面
        /// </summary>
        public string title { get; set; }

        public List<RuleData> pingzhengdu { get; set; }
        public List<RuleData> chuizhidu { get; set; }
    }

    public class UpdateReportDto
    {
        public Guid TaskId { get; set; }
        public int PointIndex { get; set; }
        public Guid OpraterID { get; set; }
    }

    /// <summary>
    /// tackpointchangejson靠尺变更信息
    /// </summary>
    public class WallRulerChangeDto
    {
        /// <summary>
        /// 任务ID
        /// </summary>
        public Guid TaskId { get; set; }

        /// <summary>
        /// 站点索引
        /// </summary>
        public int PointIndex { get; set; }

        /// <summary>
        /// 墙面
        /// </summary>
        public string WallPicId { get; set; }

        /// <summary>
        /// 靠尺
        /// </summary>
        public List<RuleData> RulerDatas { get; set; }
    }

    public enum AreaEnum
    { 低 = 0, 中 = 1, 高 = 2 }

    public static class PicConfig
    {
        /// <summary>
        /// 默认打磨量为2
        /// </summary>
        public static decimal GrindingAmount { get; set; } = 2;

        /// <summary>
        /// 默认面积
        /// </summary>
        public static AreaEnum Area { get; set; } = AreaEnum.中;
    }

    /// <summary>
    /// 重新生成图片
    /// </summary>
    public class RedrawDto
    {
        /// <summary>
        /// 任务ID
        /// </summary>
        [Required] public Guid TaskId { get; set; }

        /// <summary>
        /// 任务站点索引
        /// </summary>
        [Required, Range(1, 1000)] public int PointIndex { get; set; }

        /// <summary>
        /// 热力图URL
        /// </summary>
        [Required] public string PicturePath { get; set; }

        /// <summary>
        /// 热力图ID(不带后缀的图片名称)
        /// </summary>
        public string WallPicId { get; set; }

        /// <summary>
        /// 打磨量 [0,10]
        /// </summary>
        [Range(0, 10)] public decimal GrindingAmount { get; set; } = PicConfig.GrindingAmount;

        /// <summary>
        /// 面积:高 中 低
        /// </summary>
        public AreaEnum Area { get; set; } = PicConfig.Area;
    }

    /// <summary>
    /// 是否显示
    /// </summary>
    public class IsShowDto
    {
        /// <summary>
        /// 任务ID
        /// </summary>
        public Guid TaskId { get; set; }

        /// <summary>
        /// 任务站点索引
        /// </summary>
        public int PointIndex { get; set; }

        /// <summary>
        /// 是否显示垂直
        /// </summary>
        public bool ShowVertical { get; set; } = false;

        /// <summary>
        /// 是否显示水平
        /// </summary>
        public bool ShowHorizontal { get; set; } = false;

        /// <summary>
        /// 图片ID
        /// </summary>
        public string WallPicId { get; set; }
    }

    /// <summary>
    /// 是否显示
    /// </summary>
    public class AlgorithmParameter
    {
        public string Name { get; set; }

        public string Value { get; set; }
    }

    public class AlgorithmSettingDto
    {
        /// <summary>
        /// 任务ID
        /// </summary>
        [Required] public Guid TaskId { get; set; }

        /// <summary>
        /// 任务站点索引
        /// </summary>
        [Required] public int PointIndex { get; set; }

        /// <summary>
        /// 热力图ID(不带后缀的热力图名称)
        /// </summary>
        [Required] public string WallPicId { get; set; }

        /// <summary>
        /// 靠尺图URL
        /// </summary>
        [Required] public string PicturePath { get; set; }

        /// <summary>
        /// 平整度一级选项
        /// </summary>
        public bool FlatnessRuler { get; set; }

        /// <summary>
        /// 垂直度一级选项
        /// </summary>
        public bool VerticalRuler { get; set; }
    }

    /// <summary>
    /// 图片类型枚举
    /// </summary>
    public enum PictureTypeEnum
    {
        热力图 = 0,
        俯瞰图 = 1,
        垂直度 = 2,
        平整度 = 3,
        普通图 = 4,
    }

    public class CodeName
    {
        public string Code { get; set; }

        /// <summary>
        /// 测量项Key
        /// </summary>
        public List<string> MeasureCodes { get; set; } = new List<string>();

        /// <summary>
        /// 图片类型
        /// </summary>
        public PictureTypeEnum Type { get; set; }

        public List<string> ValueList { get; set; }
    }

    /// <summary>
    /// 任务点
    /// </summary>
    public class PointDto
    {
        /// <summary>
        /// 任务ID
        /// </summary>
        [Required] public Guid TaskId { get; set; }

        /// <summary>
        /// 任务站点索引
        /// </summary>
        [Required] public int PointIndex { get; set; }
    }

    /// <summary>
    /// 俯视图与墙面图信息
    /// </summary>
    public class MsPicDto
    {
        /// <summary>
        /// 任务ID
        /// </summary>
        public Guid TaskId { get; set; }

        /// <summary>
        /// 任务站点索引
        /// </summary>
        public int PointIndex { get; set; }

        /// <summary>
        /// 房间俯视图
        /// </summary>
        public string planform_path { get; set; }

        /// <summary>
        /// 开间进深
        /// </summary>
        public string bay_depth { get; set; }

        #region 楼板板底水平度

        /// <summary>
        /// 楼板板底水平度
        /// </summary>
        public List<string> ceiling_levelness { get; set; } = new List<string>();

        /// <summary>
        /// 楼板板底水平度
        /// </summary>
        public List<string> bay_window_levelness { get; set; } = new List<string>();

        /// <summary>
        /// 多天花
        /// </summary>
        public List<string> platfondMeasure { get; set; } = new List<string>();

        /// <summary>
        /// 一米线底图
        /// </summary>
        public string floorheight { get; set; }

        /// <summary>
        /// 净高底图
        /// </summary>
        public string netheight { get; set; }

        /// <summary>
        /// 门洞尺寸底图
        /// </summary>
        public List<string> hole { get; set; } = new List<string>();

        #endregion 楼板板底水平度

        /// <summary>
        /// 地面水平度
        /// </summary>
        public string floor_levelness { get; set; }

        /// <summary>
        /// 方正性
        /// </summary>
        public string squareness { get; set; }

        /// <summary>
        /// 阴阳角
        /// </summary>
        public string yinyangjiao { get; set; }

        /// <summary>
        /// 阴阳角直线度
        /// </summary>
        public string yinyangstraight { get; set; }

        /// <summary>
        /// 墙面图信息
        /// </summary>
        public List<WallPicDto> WallPicDtos { get; set; }

        ///// <summary>
        ///// 类型字典
        ///// </summary>
        //public Dictionary<string, string> DicType { get; set; } = new Dictionary<string, string>();

        //public Dictionary<string, List<string>> DicType2 { get; set; } = new Dictionary<string, List<string>>();

        /// <summary>
        /// 类型字典
        /// </summary>
        public static List<CodeName> DicType { get; set; } = new List<CodeName>();

        public List<ImageData> ImageDatas { get; set; } = new List<ImageData>();

        /// <summary>
        /// "wall_flat"数组成员，"title"为墙面编号，得到当前墙面后，获取data数组，里面的"title"为靠尺编号，"value"为靠尺值
        /// </summary>
        public List<WallRuler> wall_flat { get; set; }

        /// <summary>
        /// "vertical_flat"数组成员，"title"为墙面编号，得到当前墙面后，获取data数组，里面的"title"为靠尺编号，"value"为靠尺值
        /// </summary>
        public List<WallRuler> vertical_flat { get; set; }

        /// <summary>
        /// 3D图片列表
        /// </summary>
        public List<string> ThreeImageList { get; set; } = new List<string>();

        /// <summary>
        /// 3D图片相关的json文件列表
        /// </summary>
        public List<string> ThreeJsonList { get; set; } = new List<string>();

        /// <summary>
        /// 热力图和靠尺图是否拆分
        /// </summary>
        public bool IsRulerSplit { get; set; }

        static MsPicDto()
        {
            /*
             * ceiling_levelness.png  楼板板底水平度
             * bay_window_levelness.png 楼板板底水平度
             * floor_levelness.png 地面水平度
             * bay_depth.png 开间进深
             * yinyangjiao.png 阴阳角
             * squareness.png 方正性
             * planform.png 房间俯视图
             * W11_hotmap.png 墙面热力图
             * W11_flatness.png 墙面平整度靠尺图
             * Wll_vertical.png 墙面垂直度靠尺图
             * C1_hotmap.png 天花热力图
             * C1_flatness.png 天花平整度靠尺图
             * F1_hotmap.png 地面热力图
             * F1_flatness.png 地面平整度靠尺图
             */

            //楼板板底水平度（多张图片）
            //地面水平度（1张图片）
            //开间进深（1张图片）
            //阴阳角（1张图片）
            //方正性（1张图片）
            //墙面爆点（多张图片）
            //天花爆点（1张图片）
            //地面爆点（1张图片）
            List<string> temp = new List<string>() { "r-pingzhengdu", "r-chuizhidu" };
            DicType.Add(new CodeName() { Code = "墙面爆点", MeasureCodes = temp, Type = PictureTypeEnum.热力图, ValueList = new List<string>() { "W_hotmap" } });
            temp = new List<string>() { "r-tianhuapingzhengdu" };
            DicType.Add(new CodeName() { Code = "天花爆点", MeasureCodes = temp, Type = PictureTypeEnum.热力图, ValueList = new List<string>() { "C_hotmap" } });
            temp = new List<string>() { "r-dimianpingzhengdu" };
            DicType.Add(new CodeName() { Code = "地面爆点", MeasureCodes = temp, Type = PictureTypeEnum.热力图, ValueList = new List<string>() { "F_hotmap" } });
            temp = new List<string>() { "r-loubanbandishuipingdu" };
            DicType.Add(new CodeName() { Code = "楼板板底水平度", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "ceiling_levelness", "bay_window_levelness" } });
            temp = new List<string>() { "r-dimianshuipingdu" };
            DicType.Add(new CodeName() { Code = "地面水平度", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "floor_levelness" } });
            temp = new List<string>() { "r-kaijianjinshenjicha" };
            DicType.Add(new CodeName() { Code = "开间进深", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "bay_depth" } });
            temp = new List<string>() { "r-yinyang" };
            DicType.Add(new CodeName() { Code = "阴阳角", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "yinyangjiao" } });
            temp = new List<string>() { "r-yinyangjiaozhixiandu" };
            DicType.Add(new CodeName() { Code = "阴阳角直线度", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "yinyangstraight" } });
            temp = new List<string>() { "r-fangzhengxing" };
            DicType.Add(new CodeName() { Code = "方正性", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "squareness" } });
            temp = new List<string>() { "r-tijiaoxianpingzhengdu" };
            DicType.Add(new CodeName() { Code = "踢脚线平整度", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "baseboard" } });
            temp = new List<string>() { "r-mentaoxianchuizhidu", "r-mentaoxianpingzhengdu" };
            DicType.Add(new CodeName() { Code = "门套线", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "doorline" } });
            temp = new List<string>() { "r-yimixianbiaogao" };
            DicType.Add(new CodeName() { Code = "一米线标高", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "floorheight" } });
            temp = new List<string>() { "r-jinggao" };
            DicType.Add(new CodeName() { Code = "净高", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "netheight" } });
            temp = new List<string>() { "r-menchuangdongkouchicun" };
            DicType.Add(new CodeName() { Code = "门窗洞口尺寸", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "hole" } });
            temp = new List<string>() { "r-xianhekongdong" };
            DicType.Add(new CodeName() { Code = "线盒孔洞", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "wirebox" } });
            temp = new List<string>() { "r-kongtiaokongdong" };
            DicType.Add(new CodeName() { Code = "空调孔洞", MeasureCodes = temp, Type = PictureTypeEnum.普通图, ValueList = new List<string>() { "airconditionhole" } });
        }
    }

    public class HotmapModel
    {
        public string TaskId { get; set; }
        public int PointIndex { get; set; }
        public string planform_path { get; set; }
        public string bay_depth { get; set; }
        public string ceiling_levelness { get; set; }
        public List<object> bay_window_levelness { get; set; }
        public string floor_levelness { get; set; }
        public string squareness { get; set; }
        public string yinyangjiao { get; set; }
        public List<WallPicDto> WallPicDtos { get; set; }
        public List<ImageData> ImageDatas { get; set; }
        public object wall_flat { get; set; }
        public object vertical_flat { get; set; }
    }

    /// <summary>
    /// 算法生成图片集合
    /// </summary>
    public class ImageData
    {
        public string Code { get; set; }
        public string Key { get; set; }

        /// <summary>
        /// 墙面编号
        /// </summary>
        //public string Id { get; set; }
        public List<string> MeasureCodes { get; set; }

        public List<ImageModel> ImageModels { get; set; }
    }

    /// <summary>
    /// 算法生成图片实体
    /// </summary>
    public class ImageModel
    {
        /// <summary>
        /// 墙面
        /// </summary>
        public string Id { get; set; }

        public string Code { get; set; }

        /// <summary>
        /// 墙面底图
        /// </summary>
        public string BasemapUrl { get; set; }

        /// <summary>
        /// 热力图路径
        /// </summary>
        public string HotmapUrl { get; set; }

        /// <summary>
        /// 垂直度
        /// </summary>
        public string VerticalUrl { get; set; }

        /// <summary>
        /// 平整度
        /// </summary>
        public string FlatnessUrl { get; set; }

        /// <summary>
        /// 靠尺图
        /// </summary>
        public string RulesUrl { get; set; }

        /// <summary>
        /// 打磨量 int 1-10
        /// </summary>
        public decimal GrindingAmount { get; set; } = PicConfig.GrindingAmount;

        /// <summary>
        /// 面积:高 中 低
        /// </summary>
        public string Area { get; set; } = PicConfig.Area.ToString();

        /// <summary>
        /// 是否显示垂直
        /// </summary>
        public bool ShowVertical { get; set; } = true;

        /// <summary>
        /// 是否显示水平
        /// </summary>
        public bool ShowFlatness { get; set; } = true;

        /// <summary>
        /// 平整度一级选项
        /// </summary>
        public bool FlatnessRuler { get; set; } = true;

        /// <summary>
        /// 垂直度一级选项
        /// </summary>
        public bool VerticalRuler { get; set; } = true;

        /// <summary>
        /// 平整度标准位置靠尺
        /// </summary>
        public bool StandardFlatnessRuler { get; set; } = true;

        /// <summary>
        /// 垂直度标准位置靠尺
        /// </summary>
        public bool StandardVerticalRuler { get; set; }

        /// <summary>
        /// 平整度满测的合格尺
        /// </summary>
        public bool FullFlatnessValidRuler { get; set; } = true;

        /// <summary>
        /// 平整度满测的爆点尺
        /// </summary>
        public bool FullFlatnessInvalidRuler { get; set; } = true;

        /// <summary>
        /// 垂直度的合格尺
        /// </summary>
        public bool VerticalValidRuler { get; set; } = true;

        /// <summary>
        /// 垂直度的爆点尺
        /// </summary>
        public bool VerticalInvalidRuler { get; set; } = true;

        /// <summary>
        /// 水平度靠尺信息
        /// </summary>
        //public List<RuleData> WalLFlatRulerInfo { get; set; }

        /// <summary>
        /// 靠尺信息
        /// </summary>
        public List<RuleData> RulerDatas { get; set; }
    }

    /// <summary>
    /// 靠尺类型
    /// </summary>
    public enum RulerType
    { wall_flat = 0, vertical_flat = 1 }

    /// <summary>
    /// 靠尺信息
    /// </summary>
    public class Ruler
    {
        /// <summary>
        /// 靠尺是否显示，否：false，是：true。靠尺屏蔽优先级高于靠尺值修改，只有true时，修改的靠尺值才有效
        /// </summary>
        public bool Flag { get; set; }

        /// <summary>
        /// 靠尺编号
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 靠尺类型
        /// </summary>
        public RulerType RulerType { get; set; }

        /// <summary>
        /// 靠尺值
        /// </summary>
        public decimal RulerValue { get; set; }
    }

    /// <summary>
    /// 墙面图信息
    /// </summary>
    public class WallPicDto
    {
        /// <summary>
        /// 图片ID
        /// </summary>
        public string WallPicId { get; set; }

        /// <summary>
        /// 图片路径
        /// </summary>
        public string PicPath { get; set; }

        /// <summary>
        /// 墙面热力图路径
        /// </summary>
        public string WallHotViewPath { get; set; }

        /// <summary>
        /// 墙面垂直度靠尺图路径
        /// </summary>
        public string WallVerticalViewPath { get; set; }

        /// <summary>
        /// 墙面平整度靠尺图路径
        /// </summary>
        public string WallHorizontalView { get; set; }

        /// <summary>
        /// C1_hotmap.png 天花热力图
        /// </summary>
        public string C_hotmap { get; set; }

        /// <summary>
        ///C1_flatness.png 天花平整度靠尺图
        /// </summary>
        public string C_flatness { get; set; }

        /// <summary>
        /// F1_hotmap.png 地面热力图
        /// </summary>
        public string F_hotmap { get; set; }

        /// <summary>
        /// F1_flatness.png 地面平整度靠尺图
        /// </summary>
        public string F_flatness { get; set; }

        /// <summary>
        /// 打磨量 int 1-10
        /// </summary>
        public decimal GrindingAmount { get; set; } = PicConfig.GrindingAmount;

        /// <summary>
        /// 面积:高 中 低
        /// </summary>
        public string Area { get; set; } = PicConfig.Area.ToString();

        /// <summary>
        /// 是否显示垂直
        /// </summary>
        public bool ShowVertical { get; set; } = true;

        /// <summary>
        /// 是否显示水平
        /// </summary>
        public bool ShowHorizontal { get; set; } = true;

        /// <summary>
        /// 平整度一级选项
        /// </summary>
        public bool FlatnessRuler { get; set; } = true;

        /// <summary>
        /// 垂直度一级选项
        /// </summary>
        public bool VerticalRuler { get; set; } = true;

        /// <summary>
        /// 平整度标准位置靠尺
        /// </summary>
        public bool StandardFlatnessRuler { get; set; } = false;

        /// <summary>
        /// 垂直度标准位置靠尺
        /// </summary>
        public bool StandardVerticalRuler { get; set; } = false;

        /// <summary>
        /// 平整度满测的合格尺
        /// </summary>
        public bool FullFlatnessValidRuler { get; set; } = false;

        /// <summary>
        /// 平整度满测的爆点尺
        /// </summary>
        public bool FullFlatnessInvalidRuler { get; set; } = true;

        /// <summary>
        /// 垂直度的合格尺
        /// </summary>
        public bool VerticalValidRuler { get; set; } = false;

        /// <summary>
        /// 垂直度的爆点尺
        /// </summary>
        public bool VerticalInvalidRuler { get; set; } = true;

        /// <summary>
        /// 类型代码：如：墙面爆点，天花爆点等
        /// </summary>
        public string Code { get; set; }
    }
}